<?php
require_once __DIR__ . "/include_common.php";
function newDB()
{
    global $GLOBALS_CONFIGS;
    if (!isset($GLOBALS_CONFIGS['db']) || !isset($GLOBALS_CONFIGS['db']['default'])) {
        throw new \Exception("数据库配置异常");
    }
//        $dsn="mysql:host=127.0.0.1;dbname=test";
    $config = $GLOBALS_CONFIGS['db']['default'];
    $dsn = "{$config['driver']}:host={$config['host']};dbname={$config['database']}";
    $pdo = new \PDO($dsn, $config['username'], $config['password']);
    return $pdo;
}

$manager = new \Illuminate\Database\Capsule\Manager();
$manager->addConnection(['driver' => 'mysql'], "default");
$manager->getConnection("default")->setPdo(newDB());
$manager->setAsGlobal();
$manager->bootEloquent();
$user = $manager::table("user")->first();
var_dump($user);
